Lines 167-172
Link Here
|
167 |
return mpCharMap; |
167 |
return mpCharMap; |
168 |
} |
168 |
} |
169 |
|
169 |
|
|
|
170 |
bool ImplMacFontData::ReadOs2Table(std::vector<unsigned char> &rBuffer) const |
171 |
{ |
172 |
ATSFontRef rFont = FMGetATSFontRefFromFont( mnFontId ); |
173 |
ByteCount nBufSize = 0; |
174 |
OSStatus eStatus = ATSFontGetTable( rFont, GetTag("OS/2"), 0, 0, NULL, &nBufSize ); |
175 |
DBG_ASSERT( (eStatus==noErr), "ImplMacFontData::ReadOs2Table : ATSFontGetTable1 failed!\n"); |
176 |
if( eStatus != noErr ) |
177 |
return false; |
178 |
|
179 |
// allocate a buffer for the OS/2 raw data |
180 |
rBuffer.resize( nBufSize ); |
181 |
|
182 |
// get the OS/2 raw data |
183 |
ByteCount nRawLength = 0; |
184 |
eStatus = ATSFontGetTable( rFont, GetTag("OS/2"), 0, nBufSize, (void*)&rBuffer[0], &nRawLength ); |
185 |
DBG_ASSERT( (eStatus==noErr), "ImplMacFontData::ReadOs2Table : ATSFontGetTable2 failed!\n"); |
186 |
if( eStatus != noErr ) |
187 |
return false; |
188 |
DBG_ASSERT( (nBufSize==nRawLength), "ImplMacFontData::ReadOs2Table : ByteCount mismatch!\n"); |
189 |
|
190 |
// parse the OS/2 |
191 |
return true; |
192 |
} |
193 |
|
194 |
|
170 |
// ======================================================================= |
195 |
// ======================================================================= |
171 |
|
196 |
|
172 |
AquaSalGraphics::AquaSalGraphics() |
197 |
AquaSalGraphics::AquaSalGraphics() |
Lines 1130-1135
Link Here
|
1130 |
} |
1155 |
} |
1131 |
|
1156 |
|
1132 |
// ----------------------------------------------------------------------- |
1157 |
// ----------------------------------------------------------------------- |
|
|
1158 |
static unsigned GetUShort( const unsigned char* p ){return((p[0]<<8)+p[1]);} |
1159 |
static unsigned GetUInt( const unsigned char* p ) { return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);} |
1133 |
|
1160 |
|
1134 |
void AquaSalGraphics::GetFontMetric( ImplFontMetricData* pMetric ) |
1161 |
void AquaSalGraphics::GetFontMetric( ImplFontMetricData* pMetric ) |
1135 |
{ |
1162 |
{ |
Lines 1166-1171
Link Here
|
1166 |
// setting this width to the pixel height of the fontsize is good enough |
1193 |
// setting this width to the pixel height of the fontsize is good enough |
1167 |
// it also makes the calculation of the stretch factor simple |
1194 |
// it also makes the calculation of the stretch factor simple |
1168 |
pMetric->mnWidth = fPixelSize + 0.5; |
1195 |
pMetric->mnWidth = fPixelSize + 0.5; |
|
|
1196 |
|
1197 |
|
1198 |
ByteVector aBuffer; |
1199 |
if( !ReadOs2Table( aBuffer ) ) |
1200 |
return; |
1201 |
unsigned char* pOS2map = &aBuffer[0]; |
1202 |
sal_uInt32 nVersion = GetUShort( pOS2map ); |
1203 |
bool bHasCJKSupport = false; |
1204 |
if (nVersion >= 0x0001) |
1205 |
{ |
1206 |
sal_uInt32 ulUnicodeRange2 = GetUInt( pOS2map + 46 ); |
1207 |
if (ulUnicodeRange2 & 0x2DF00000) |
1208 |
bHasCJKSupport = true; |
1209 |
} |
1210 |
|
1211 |
if ( bHasCJKSupport ) |
1212 |
{ |
1213 |
// for Asian fonts hack |
1214 |
pMetric->mnIntLeading += pMetric->mnExtLeading; |
1215 |
|
1216 |
const long nHalfTmpExtLeading = pMetric->mnExtLeading / 2; |
1217 |
const long nOtherHalfTmpExtLeading = pMetric->mnExtLeading - nHalfTmpExtLeading; |
1218 |
|
1219 |
long nCJKExtLeading = static_cast<long>(0.30 * (pMetric->mnAscent + pMetric->mnDescent)); |
1220 |
nCJKExtLeading -= pMetric->mnExtLeading; |
1221 |
pMetric->mnExtLeading = (nCJKExtLeading > 0) ? nCJKExtLeading : 0; |
1222 |
|
1223 |
pMetric->mnAscent += nHalfTmpExtLeading; |
1224 |
pMetric->mnDescent += nOtherHalfTmpExtLeading; |
1225 |
} |
1169 |
} |
1226 |
} |
1170 |
|
1227 |
|
1171 |
// ----------------------------------------------------------------------- |
1228 |
// ----------------------------------------------------------------------- |
Lines 1460-1465
Link Here
|
1460 |
|
1517 |
|
1461 |
// ----------------------------------------------------------------------- |
1518 |
// ----------------------------------------------------------------------- |
1462 |
|
1519 |
|
|
|
1520 |
bool AquaSalGraphics::ReadOs2Table( std::vector<unsigned char>& rBuffer ) |
1521 |
{ |
1522 |
if( !mpMacFontData ) |
1523 |
return false; |
1524 |
|
1525 |
return mpMacFontData->ReadOs2Table( rBuffer ); |
1526 |
} |
1527 |
|
1528 |
// ----------------------------------------------------------------------- |
1529 |
|
1463 |
// fake a SFNT font directory entry for a font table |
1530 |
// fake a SFNT font directory entry for a font table |
1464 |
// see http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6.html#Directory |
1531 |
// see http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6.html#Directory |
1465 |
static void FakeDirEntry( FourCharCode eFCC, ByteCount nOfs, ByteCount nLen, |
1532 |
static void FakeDirEntry( FourCharCode eFCC, ByteCount nOfs, ByteCount nLen, |