Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: Source/platform/fonts/FontPlatformData.cpp

Issue 1238753005: Add unit tests for FontPlatformData::hasSpaceInLigaturesOrKerning (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Brent Fulgham 2 * Copyright (C) 2011 Brent Fulgham
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 return true; 282 return true;
283 } 283 }
284 return false; 284 return false;
285 } 285 }
286 286
287 bool FontPlatformData::hasSpaceInLigaturesOrKerning( 287 bool FontPlatformData::hasSpaceInLigaturesOrKerning(
288 TypesettingFeatures features) const 288 TypesettingFeatures features) const
289 { 289 {
290 const HarfBuzzFace* hbFace = harfBuzzFace(); 290 const HarfBuzzFace* hbFace = harfBuzzFace();
291 if (!hbFace) 291 if (!hbFace)
292 return true; 292 return false;
leviw_travelin_and_unemployed 2015/07/16 00:01:39 This makes way more sense.
293 293
294 hb_face_t* face = hbFace->face(); 294 hb_face_t* face = hbFace->face();
295 ASSERT(face); 295 ASSERT(face);
296 hb_font_t* font = hbFace->createFont(); 296 hb_font_t* font = hbFace->createFont();
297 ASSERT(font); 297 ASSERT(font);
298 298
299 hb_codepoint_t space; 299 hb_codepoint_t space;
300 // If the space glyph isn't present in the font then each space character 300 // If the space glyph isn't present in the font then each space character
301 // will be rendering using a fallback font, which grantees that it cannot 301 // will be rendering using a fallback font, which grantees that it cannot
302 // affect the shape of the preceding word. 302 // affect the shape of the preceding word.
303 if (!hb_font_get_glyph(font, spaceCharacter, 0, &space)) 303 if (!hb_font_get_glyph(font, spaceCharacter, 0, &space))
304 return true; 304 return false;
305 305
306 if (!hb_ot_layout_has_substitution(face) 306 if (!hb_ot_layout_has_substitution(face)
307 && !hb_ot_layout_has_positioning(face)) { 307 && !hb_ot_layout_has_positioning(face)) {
308 return true; 308 return false;
309 } 309 }
310 310
311 bool foundSpaceInTable = false; 311 bool foundSpaceInTable = false;
312 hb_set_t* glyphs = hb_set_create(); 312 hb_set_t* glyphs = hb_set_create();
313 if (features & Kerning) 313 if (features & Kerning)
314 foundSpaceInTable = tableHasSpace(face, glyphs, HB_OT_TAG_GPOS, space); 314 foundSpaceInTable = tableHasSpace(face, glyphs, HB_OT_TAG_GPOS, space);
315 if (!foundSpaceInTable && (features & Ligatures)) 315 if (!foundSpaceInTable && (features & Ligatures))
316 foundSpaceInTable = tableHasSpace(face, glyphs, HB_OT_TAG_GSUB, space); 316 foundSpaceInTable = tableHasSpace(face, glyphs, HB_OT_TAG_GSUB, space);
317 317
318 hb_set_destroy(glyphs); 318 hb_set_destroy(glyphs);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 const size_t tableSize = m_typeface->getTableSize(tag); 363 const size_t tableSize = m_typeface->getTableSize(tag);
364 if (tableSize) { 364 if (tableSize) {
365 Vector<char> tableBuffer(tableSize); 365 Vector<char> tableBuffer(tableSize);
366 m_typeface->getTableData(tag, 0, tableSize, &tableBuffer[0]); 366 m_typeface->getTableData(tag, 0, tableSize, &tableBuffer[0]);
367 buffer = SharedBuffer::adoptVector(tableBuffer); 367 buffer = SharedBuffer::adoptVector(tableBuffer);
368 } 368 }
369 return buffer.release(); 369 return buffer.release();
370 } 370 }
371 371
372 } // namespace blink 372 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698