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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); | 186 extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); |
187 extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); | 187 extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 static hb_bool_t harfBuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoin
t_t unicode, hb_codepoint_t variationSelector, hb_codepoint_t* glyph, void* user
Data) | 191 static hb_bool_t harfBuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoin
t_t unicode, hb_codepoint_t variationSelector, hb_codepoint_t* glyph, void* user
Data) |
192 { | 192 { |
193 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData)
; | 193 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData)
; |
194 | 194 |
195 if (variationSelector) { | 195 if (variationSelector) { |
196 #if OS(LINUX) | |
197 // TODO(kojii): Linux non-official builds cannot use new HB APIs | |
198 // until crbug.com/462689 resolved or pangoft2 updates its HB. | |
199 return false; | |
200 #else | |
201 // Skia does not support variation selectors, but hb does. | 196 // Skia does not support variation selectors, but hb does. |
202 // We're not fully ready to switch to hb-ot-font yet, | 197 // We're not fully ready to switch to hb-ot-font yet, |
203 // but are good enough to get glyph IDs for OpenType fonts. | 198 // but are good enough to get glyph IDs for OpenType fonts. |
204 if (!hbFontData->m_hbOpenTypeFont) { | 199 if (!hbFontData->m_hbOpenTypeFont) { |
205 hbFontData->m_hbOpenTypeFont = hb_font_create(hbFontData->m_face); | 200 hbFontData->m_hbOpenTypeFont = hb_font_create(hbFontData->m_face); |
206 hb_ot_font_set_funcs(hbFontData->m_hbOpenTypeFont); | 201 hb_ot_font_set_funcs(hbFontData->m_hbOpenTypeFont); |
207 } | 202 } |
208 return hb_font_get_glyph(hbFontData->m_hbOpenTypeFont, unicode, variatio
nSelector, glyph); | 203 return hb_font_get_glyph(hbFontData->m_hbOpenTypeFont, unicode, variatio
nSelector, glyph); |
209 // When not found, glyph_func should return false rather than fallback t
o the base. | 204 // When not found, glyph_func should return false rather than fallback t
o the base. |
210 // http://lists.freedesktop.org/archives/harfbuzz/2015-May/004888.html | 205 // http://lists.freedesktop.org/archives/harfbuzz/2015-May/004888.html |
211 #endif | |
212 } | 206 } |
213 | 207 |
214 WTF::HashMap<uint32_t, uint16_t>::AddResult result = hbFontData->m_glyphCach
eForFaceCacheEntry->add(unicode, 0); | 208 WTF::HashMap<uint32_t, uint16_t>::AddResult result = hbFontData->m_glyphCach
eForFaceCacheEntry->add(unicode, 0); |
215 if (result.isNewEntry) { | 209 if (result.isNewEntry) { |
216 SkPaint* paint = &hbFontData->m_paint; | 210 SkPaint* paint = &hbFontData->m_paint; |
217 paint->setTextEncoding(SkPaint::kUTF32_TextEncoding); | 211 paint->setTextEncoding(SkPaint::kUTF32_TextEncoding); |
218 uint16_t glyph16; | 212 uint16_t glyph16; |
219 paint->textToGlyphs(&unicode, sizeof(hb_codepoint_t), &glyph16); | 213 paint->textToGlyphs(&unicode, sizeof(hb_codepoint_t), &glyph16); |
220 result.storedValue->value = glyph16; | 214 result.storedValue->value = glyph16; |
221 *glyph = glyph16; | 215 *glyph = glyph16; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 hb_font_t* font = hb_font_create(m_face); | 360 hb_font_t* font = hb_font_create(m_face); |
367 hb_font_set_funcs(font, harfBuzzSkiaGetFontFuncs(), hbFontData, destroyHarfB
uzzFontData); | 361 hb_font_set_funcs(font, harfBuzzSkiaGetFontFuncs(), hbFontData, destroyHarfB
uzzFontData); |
368 float size = m_platformData->size(); | 362 float size = m_platformData->size(); |
369 int scale = SkiaScalarToHarfBuzzPosition(size); | 363 int scale = SkiaScalarToHarfBuzzPosition(size); |
370 hb_font_set_scale(font, scale, scale); | 364 hb_font_set_scale(font, scale, scale); |
371 hb_font_make_immutable(font); | 365 hb_font_make_immutable(font); |
372 return font; | 366 return font; |
373 } | 367 } |
374 | 368 |
375 } // namespace blink | 369 } // namespace blink |
OLD | NEW |