src/macosx/native/sun/font/CGGlyphImages.m

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 453,462 **** --- 453,463 ---- * Creates a GlyphInfo with exactly the correct size image and measurements. */ #define CGGI_GLYPH_BBOX_PADDING 2.0f static inline GlyphInfo * CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox, + const AWTStrike *strike, const CGGI_RenderingMode *mode) { size_t pixelSize = mode->glyphDescriptor->pixelSize; // adjust the bounding box to be 1px bigger on each side than what
*** 475,484 **** --- 476,491 ---- // and zero pixels is ok if (width * height > 1024 * 1024) { width = 1; height = 1; } + advance = CGSizeApplyAffineTransform(advance, strike->fFontTx); + if (!JRSFontStyleUsesFractionalMetrics(strike->fStyle)) { + advance.width = round(advance.width); + advance.height = round(advance.height); + } + advance = CGSizeApplyAffineTransform(advance, strike->fDevTx); #ifdef USE_IMAGE_ALIGNED_MEMORY // create separate memory GlyphInfo *glyphInfo = (GlyphInfo *)malloc(sizeof(GlyphInfo)); void *image = (void *)malloc(height * width * pixelSize);
*** 562,575 **** CGRect bbox; JRSFontGetBoundingBoxesForGlyphsAndStyle(fallback, &tx, style, &glyph, 1, &bbox); CGSize advance; ! JRSFontGetAdvancesForGlyphsAndStyle(fallback, &tx, strike->fStyle, &glyph, 1, &advance); // create the Sun2D GlyphInfo we are going to strike into ! GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, mode); // fix the context size, just in case the substituted character is unexpectedly large CGGI_SizeCanvas(canvas, info->width, info->height, mode->cgFontMode); // align the transform for the real CoreText strike --- 569,582 ---- CGRect bbox; JRSFontGetBoundingBoxesForGlyphsAndStyle(fallback, &tx, style, &glyph, 1, &bbox); CGSize advance; ! CTFontGetAdvancesForGlyphs(fallback, kCTFontDefaultOrientation, &glyph, &advance, 1); // create the Sun2D GlyphInfo we are going to strike into ! GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, mode); // fix the context size, just in case the substituted character is unexpectedly large CGGI_SizeCanvas(canvas, info->width, info->height, mode->cgFontMode); // align the transform for the real CoreText strike
*** 713,723 **** AWTFont *font = strike->fAWTFont; CGAffineTransform tx = strike->fTx; JRSFontRenderingStyle bboxCGMode = JRSFontAlignStyleForFractionalMeasurement(strike->fStyle); JRSFontGetBoundingBoxesForGlyphsAndStyle((CTFontRef)font->fFont, &tx, bboxCGMode, glyphs, len, bboxes); ! JRSFontGetAdvancesForGlyphsAndStyle((CTFontRef)font->fFont, &tx, strike->fStyle, glyphs, len, advances); size_t maxWidth = 1; size_t maxHeight = 1; CFIndex i; --- 720,730 ---- AWTFont *font = strike->fAWTFont; CGAffineTransform tx = strike->fTx; JRSFontRenderingStyle bboxCGMode = JRSFontAlignStyleForFractionalMeasurement(strike->fStyle); JRSFontGetBoundingBoxesForGlyphsAndStyle((CTFontRef)font->fFont, &tx, bboxCGMode, glyphs, len, bboxes); ! CTFontGetAdvancesForGlyphs((CTFontRef)font->fFont, kCTFontDefaultOrientation, glyphs, advances, len); size_t maxWidth = 1; size_t maxHeight = 1; CFIndex i;
*** 730,740 **** } CGSize advance = advances[i]; CGRect bbox = bboxes[i]; ! GlyphInfo *glyphInfo = CGGI_CreateNewGlyphInfoFrom(advance, bbox, mode); if (maxWidth < glyphInfo->width) maxWidth = glyphInfo->width; if (maxHeight < glyphInfo->height) maxHeight = glyphInfo->height; glyphInfos[i] = ptr_to_jlong(glyphInfo); --- 737,747 ---- } CGSize advance = advances[i]; CGRect bbox = bboxes[i]; ! GlyphInfo *glyphInfo = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, mode); if (maxWidth < glyphInfo->width) maxWidth = glyphInfo->width; if (maxHeight < glyphInfo->height) maxHeight = glyphInfo->height; glyphInfos[i] = ptr_to_jlong(glyphInfo);