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