1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 1999-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: SimpleFontInstance.cpp
*
* created on: 03/30/2006
* created by: Eric R. Mader
*/
#include "unicode/utypes.h"
#include "unicode/uchar.h"
#include "layout/LETypes.h"
#include "layout/LEFontInstance.h"
#include "SimpleFontInstance.h"
SimpleFontInstance::SimpleFontInstance(float pointSize, LEErrorCode &status)
: fPointSize(pointSize), fAscent(0), fDescent(0)
{
if (LE_FAILURE(status)) {
return;
}
fAscent = static_cast<le_int32>(yUnitsToPoints(2000.0));
fDescent = static_cast<le_int32>(yUnitsToPoints(600.0));
}
SimpleFontInstance::~SimpleFontInstance()
{
// nothing to do...
}
const void *SimpleFontInstance::getFontTable(LETag /*tableTag*/, size_t &length) const
{
length = -1; // unknown for this test.
return nullptr;
}
void SimpleFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
{
#if 0
if (u_getCombiningClass((UChar32) glyph) == 0) {
advance.fX = xUnitsToPoints(2048);
} else {
advance.fX = 0;
}
#else
(void)glyph; // Suppress unused parameter compiler warning.
advance.fX = xUnitsToPoints(2048);
#endif
advance.fY = 0;
}
le_int32 SimpleFontInstance::getUnitsPerEM() const
{
return 2048;
}
le_int32 SimpleFontInstance::getAscent() const
{
return fAscent;
}
le_int32 SimpleFontInstance::getDescent() const
{
return fDescent;
}
le_int32 SimpleFontInstance::getLeading() const
{
return 0;
}
// We really want to inherit this method from the superclass, but some compilers
// issue a warning if we don't implement it...
LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
{
return LEFontInstance::mapCharToGlyph(ch, mapper, filterZeroWidth);
}
// We really want to inherit this method from the superclass, but some compilers
// issue a warning if we don't implement it...
LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
{
return LEFontInstance::mapCharToGlyph(ch, mapper);
}
LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch) const
{
return static_cast<LEGlyphID>(ch);
}
float SimpleFontInstance::getXPixelsPerEm() const
{
return fPointSize;
}
float SimpleFontInstance::getYPixelsPerEm() const
{
return fPointSize;
}
float SimpleFontInstance::getScaleFactorX() const
{
return 1.0;
}
float SimpleFontInstance::getScaleFactorY() const
{
return 1.0;
}
le_bool SimpleFontInstance::getGlyphPoint(LEGlyphID /*glyph*/, le_int32 /*pointNumber*/, LEPoint &/*point*/) const
{
return false;
}
|