OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 CGGlyph cgGlyph = glyph; | 78 CGGlyph cgGlyph = glyph; |
79 if (CTFontGetBoundingRectsForGlyphs(ctFont, kCTFontDefaultOrientation, &cgGl
yph, &cgRect, 1) == CGRectNull) | 79 if (CTFontGetBoundingRectsForGlyphs(ctFont, kCTFontDefaultOrientation, &cgGl
yph, &cgRect, 1) == CGRectNull) |
80 return false; | 80 return false; |
81 extents->x_bearing = floatToHarfBuzzPosition(cgRect.origin.x); | 81 extents->x_bearing = floatToHarfBuzzPosition(cgRect.origin.x); |
82 extents->y_bearing = -floatToHarfBuzzPosition(cgRect.origin.y); | 82 extents->y_bearing = -floatToHarfBuzzPosition(cgRect.origin.y); |
83 extents->width = floatToHarfBuzzPosition(cgRect.size.width); | 83 extents->width = floatToHarfBuzzPosition(cgRect.size.width); |
84 extents->height = floatToHarfBuzzPosition(cgRect.size.height); | 84 extents->height = floatToHarfBuzzPosition(cgRect.size.height); |
85 return true; | 85 return true; |
86 } | 86 } |
87 | 87 |
88 static hb_font_funcs_t* harfBuzzCoreTextGetFontFuncs() | 88 static hb_font_funcs_t* harfBuzzCoreTextGetFontFuncs(const TypesettingFeatures&) |
89 { | 89 { |
90 static hb_font_funcs_t* harfBuzzCoreTextFontFuncs = 0; | 90 static hb_font_funcs_t* harfBuzzCoreTextFontFuncs = 0; |
91 | 91 |
92 if (!harfBuzzCoreTextFontFuncs) { | 92 if (!harfBuzzCoreTextFontFuncs) { |
93 harfBuzzCoreTextFontFuncs = hb_font_funcs_create(); | 93 harfBuzzCoreTextFontFuncs = hb_font_funcs_create(); |
94 hb_font_funcs_set_glyph_func(harfBuzzCoreTextFontFuncs, getGlyph, 0, 0); | 94 hb_font_funcs_set_glyph_func(harfBuzzCoreTextFontFuncs, getGlyph, 0, 0); |
95 hb_font_funcs_set_glyph_h_advance_func(harfBuzzCoreTextFontFuncs, getGly
phHorizontalAdvance, 0, 0); | 95 hb_font_funcs_set_glyph_h_advance_func(harfBuzzCoreTextFontFuncs, getGly
phHorizontalAdvance, 0, 0); |
96 hb_font_funcs_set_glyph_h_origin_func(harfBuzzCoreTextFontFuncs, getGlyp
hHorizontalOrigin, 0, 0); | 96 hb_font_funcs_set_glyph_h_origin_func(harfBuzzCoreTextFontFuncs, getGlyp
hHorizontalOrigin, 0, 0); |
97 hb_font_funcs_set_glyph_extents_func(harfBuzzCoreTextFontFuncs, getGlyph
Extents, 0, 0); | 97 hb_font_funcs_set_glyph_extents_func(harfBuzzCoreTextFontFuncs, getGlyph
Extents, 0, 0); |
98 hb_font_funcs_make_immutable(harfBuzzCoreTextFontFuncs); | 98 hb_font_funcs_make_immutable(harfBuzzCoreTextFontFuncs); |
(...skipping 23 matching lines...) Expand all Loading... |
122 | 122 |
123 hb_face_t* HarfBuzzFace::createFace() | 123 hb_face_t* HarfBuzzFace::createFace() |
124 { | 124 { |
125 // It seems that CTFontCopyTable of MacOSX10.5 sdk doesn't work for | 125 // It seems that CTFontCopyTable of MacOSX10.5 sdk doesn't work for |
126 // OpenType layout tables(GDEF, GSUB, GPOS). Use CGFontCopyTableForTag inste
ad. | 126 // OpenType layout tables(GDEF, GSUB, GPOS). Use CGFontCopyTableForTag inste
ad. |
127 hb_face_t* face = hb_face_create_for_tables(harfBuzzCoreTextGetTable, m_plat
formData->cgFont(), 0); | 127 hb_face_t* face = hb_face_create_for_tables(harfBuzzCoreTextGetTable, m_plat
formData->cgFont(), 0); |
128 ASSERT(face); | 128 ASSERT(face); |
129 return face; | 129 return face; |
130 } | 130 } |
131 | 131 |
132 hb_font_t* HarfBuzzFace::createFont() | 132 hb_font_t* HarfBuzzFace::createFont(const TypesettingFeatures& features) |
133 { | 133 { |
134 hb_font_t* font = hb_font_create(m_face); | 134 hb_font_t* font = hb_font_create(m_face); |
135 hb_font_set_funcs(font, harfBuzzCoreTextGetFontFuncs(), m_platformData, 0); | 135 hb_font_set_funcs(font, harfBuzzCoreTextGetFontFuncs(features), m_platformDa
ta, 0); |
136 const float size = m_platformData->m_size; | 136 const float size = m_platformData->m_size; |
137 hb_font_set_ppem(font, size, size); | 137 hb_font_set_ppem(font, size, size); |
138 const int scale = (1 << 16) * static_cast<int>(size); | 138 const int scale = (1 << 16) * static_cast<int>(size); |
139 hb_font_set_scale(font, scale, scale); | 139 hb_font_set_scale(font, scale, scale); |
140 hb_font_make_immutable(font); | 140 hb_font_make_immutable(font); |
141 return font; | 141 return font; |
142 } | 142 } |
143 | 143 |
144 GlyphBufferAdvance HarfBuzzShaper::createGlyphBufferAdvance(float width, float h
eight) | 144 GlyphBufferAdvance HarfBuzzShaper::createGlyphBufferAdvance(float width, float h
eight) |
145 { | 145 { |
146 return CGSizeMake(width, height); | 146 return CGSizeMake(width, height); |
147 } | 147 } |
148 | 148 |
149 } // namespace WebCore | 149 } // namespace WebCore |
OLD | NEW |