Skip to content

Commit 4976651

Browse files
authored
Merge 6a2f753 into 424ada7
2 parents 424ada7 + 6a2f753 commit 4976651

19 files changed

Lines changed: 169 additions & 44 deletions

File tree

nvdaHelper/remote/displayModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void displayModelChunk_t::generateXML(wstring& text) {
4747
s<<L"baseline=\""<<baseline<<L"\" ";
4848
s<<L"direction=\""<<direction<<L"\" ";
4949
s<<L" font-name=\""<<formatInfo.fontName<<L"\" ";
50-
s<<L" font-size=\""<<formatInfo.fontSize<<L"pt\" ";
50+
s<<L" font-size=\""<<formatInfo.fontSize<<L"\" ";
5151
if(this->formatInfo.bold) s<<L" bold=\"true\"";
5252
if(this->formatInfo.italic) s<<L" italic=\"true\"";
5353
if(this->formatInfo.underline) s<<L" underline=\"true\"";

nvdaHelper/remote/winword.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ void generateXMLAttribsForFormatting(IDispatch* pDispatchRange, int startOffset,
621621
}
622622
float fVal=0.0;
623623
if((formatConfig&formatConfig_reportFontSize)&&(_com_dispatch_raw_propget(pDispatchFont,wdDISPID_FONT_SIZE,VT_R4,&fVal)==S_OK)) {
624-
formatAttribsStream<<L"font-size=\""<<fVal<<L"pt\" ";
624+
formatAttribsStream<<L"font-size=\""<<fVal<<L"\" ";
625625
}
626626
if((formatConfig&formatConfig_reportColor)&&(_com_dispatch_raw_propget(pDispatchFont,wdDISPID_FONT_COLOR,VT_I4,&iVal)==S_OK)) {
627627
formatAttribsStream<<L"color=\""<<iVal<<L"\" ";

nvdaHelper/vbufBackends/adobeAcrobat/adobeAcrobat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ VBufStorage_fieldNode_t* renderText(VBufStorage_buffer_t* buffer,
206206
if (fontSize > 0) {
207207
wostringstream s;
208208
s.setf(ios::fixed);
209-
s << setprecision(1) << fontSize << "pt";
209+
s << setprecision(1) << fontSize;
210210
previousNode->addAttribute(L"font-size", s.str());
211211
}
212212
if ((fontFlags&PDDOM_FONTATTR_ITALIC)==PDDOM_FONTATTR_ITALIC) previousNode->addAttribute(L"italic", L"1");

source/NVDAObjects/IAccessible/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2006-2021 NV Access Limited, Babbage B.V.
2+
# Copyright (C) 2006-2022 NV Access Limited, Babbage B.V.
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
5+
56
import typing
67
from typing import (
78
Optional,
@@ -46,6 +47,7 @@
4647
import config
4748
import controlTypes
4849
from controlTypes import TextPosition
50+
from controlTypes.formatFields import FontSize
4951
from NVDAObjects.window import Window
5052
from NVDAObjects import NVDAObject, NVDAObjectTextInfo, InvalidNVDAObject
5153
import NVDAObjects.JAB
@@ -141,6 +143,10 @@ def normalizeIA2TextFormatField(formatField):
141143
except KeyError:
142144
formatField["text-position"] = TextPosition.BASELINE
143145

146+
fontSize = formatField.get("font-size")
147+
if fontSize is not None:
148+
formatField["font-size"] = FontSize.translateFromAttribute(fontSize)
149+
144150
class IA2TextTextInfo(textInfos.offsets.OffsetsTextInfo):
145151

146152
detectFormattingAfterCursorMaybeSlow=False

source/NVDAObjects/JAB/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2006-2021 NV Access Limited, Leonard de Ruijter, Joseph Lee, Renaud Paquay, pvagner
2+
# Copyright (C) 2006-2022 NV Access Limited, Leonard de Ruijter, Joseph Lee, Renaud Paquay, pvagner
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
55

@@ -177,10 +177,12 @@ def _getParagraphOffsets(self,offset):
177177
return self._getLineOffsets(offset)
178178

179179
def _getFormatFieldAndOffsets(self, offset, formatConfig, calculateOffsets=True):
180+
attribs: JABHandler.AccessibleTextAttributesInfo
180181
attribs, length = self.obj.jabContext.getTextAttributesInRange(offset, self._endOffset - 1)
181182
field = textInfos.FormatField()
182183
field["font-family"] = attribs.fontFamily
183-
field["font-size"] = "%dpt" % attribs.fontSize
184+
# Translators: Abbreviation for points, a measurement of font size.
185+
field["font-size"] = pgettext("font size", "%s pt") % str(attribs.fontSize)
184186
field["bold"] = bool(attribs.bold)
185187
field["italic"] = bool(attribs.italic)
186188
field["strikethrough"] = bool(attribs.strikethrough)

source/NVDAObjects/UIA/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ def _getFormatFieldAtRange(self,textRange,formatConfig,ignoreMixedValues=False):
221221
formatField["font-name"]=val
222222
if formatConfig["reportFontSize"]:
223223
val=fetcher.getValue(UIAHandler.UIA_FontSizeAttributeId,ignoreMixedValues=ignoreMixedValues)
224-
if isinstance(val,numbers.Number):
225-
formatField['font-size']="%g pt"%float(val)
224+
if isinstance(val, numbers.Number):
225+
# Translators: Abbreviation for points, a measurement of font size.
226+
formatField['font-size'] = pgettext("font size", "%s pt") % float(val)
226227
if formatConfig["reportFontAttributes"]:
227228
val=fetcher.getValue(UIAHandler.UIA_FontWeightAttributeId,ignoreMixedValues=ignoreMixedValues)
228229
if isinstance(val,int):

source/NVDAObjects/window/edit.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2006-2021 NV Access Limited, Babbage B.V.
2+
# Copyright (C) 2006-2022 NV Access Limited, Babbage B.V.
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
55

@@ -262,7 +262,9 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
262262
if formatConfig["reportFontSize"]:
263263
if charFormat is None: charFormat=self._getCharFormat(offset)
264264
# Font size is supposed to be an integral value
265-
formatField["font-size"]="%spt"%(charFormat.yHeight//20)
265+
fontSize = charFormat.yHeight // 20
266+
# Translators: Abbreviation for points, a measurement of font size.
267+
formatField["font-size"] = pgettext("font size", "%s pt") % fontSize
266268
if formatConfig["reportFontAttributes"]:
267269
if charFormat is None: charFormat=self._getCharFormat(offset)
268270
formatField["bold"]=bool(charFormat.dwEffects&CFE_BOLD)
@@ -507,7 +509,8 @@ def _getFormatFieldAtRange(self, textRange, formatConfig):
507509
if formatConfig["reportFontSize"]:
508510
if not fontObj:
509511
fontObj = textRange.font
510-
formatField["font-size"]="%spt"%fontObj.size
512+
# Translators: Abbreviation for points, a measurement of font size.
513+
formatField["font-size"] = pgettext("font size", "%s pt") % fontObj.size
511514
if formatConfig["reportFontAttributes"]:
512515
if not fontObj:
513516
fontObj = textRange.font

source/NVDAObjects/window/excel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2006-2020 NV Access Limited, Dinesh Kaushal, Siddhartha Gupta, Accessolutions, Julien Cochuyt
2+
# Copyright (C) 2006-2022 NV Access Limited, Dinesh Kaushal, Siddhartha Gupta, Accessolutions, Julien Cochuyt
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
55

@@ -994,7 +994,8 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
994994
if formatConfig['reportFontName']:
995995
formatField['font-name']=fontObj.name
996996
if formatConfig['reportFontSize']:
997-
formatField['font-size']=str(fontObj.size)
997+
# Translators: Abbreviation for points, a measurement of font size.
998+
formatField['font-size'] = pgettext("font size", "%s pt") % fontObj.size
998999
if formatConfig['reportFontAttributes']:
9991000
formatField['bold']=fontObj.bold
10001001
formatField['italic']=fontObj.italic

source/NVDAObjects/window/scintilla.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
127127
winKernel.virtualFreeEx(self.obj.processHandle,internalBuf,0,winKernel.MEM_RELEASE)
128128
formatField["font-name"]=fontNameBuf.value.decode("utf-8")
129129
if formatConfig["reportFontSize"]:
130-
formatField["font-size"]="%spt"%watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_STYLEGETSIZE,style,0)
130+
fontSize = watchdog.cancellableSendMessage(self.obj.windowHandle, SCI_STYLEGETSIZE, style, 0)
131+
# Translators: Abbreviation for points, a measurement of font size.
132+
formatField["font-size"] = pgettext("font size", "%s pt") % fontSize
131133
if formatConfig["reportLineNumber"]:
132134
formatField["line-number"]=self._getLineNumFromOffset(offset)+1
133135
if formatConfig["reportFontAttributes"]:

source/NVDAObjects/window/winword.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2006-2020 NV Access Limited, Manish Agrawal, Derek Riemer, Babbage B.V.
2+
# Copyright (C) 2006-2022 NV Access Limited, Manish Agrawal, Derek Riemer, Babbage B.V.
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
55

@@ -14,10 +14,6 @@
1414
from comtypes import COMError, GUID, BSTR
1515
import comtypes.client
1616
import comtypes.automation
17-
import uuid
18-
import operator
19-
import locale
20-
import collections
2117
import colorsys
2218
import eventHandler
2319
import braille
@@ -29,7 +25,6 @@
2925
from logHandler import log
3026
import winUser
3127
import oleacc
32-
import globalVars
3328
import speech
3429
import config
3530
import textInfos
@@ -900,6 +895,10 @@ def _normalizeFormatField(self,field,extraDetail=False):
900895
bullet=field.get('line-prefix')
901896
if bullet and len(bullet)==1:
902897
field['line-prefix']=mapPUAToUnicode.get(bullet,bullet)
898+
fontSize = field.get("font-size")
899+
if fontSize is not None:
900+
# Translators: Abbreviation for points, a measurement of font size.
901+
field["font-size"] = pgettext("font size", "%s pt") % fontSize
903902
return field
904903

905904
def expand(self,unit):
@@ -1476,8 +1475,8 @@ def getLocalizedMeasurementTextForPointSize(self,offset):
14761475
# Translators: a measurement in Microsoft Word
14771476
return _("{offset:.3g} millimeters").format(offset=offset)
14781477
elif unit==wdPoints:
1479-
# Translators: a measurement in Microsoft Word
1480-
return _("{offset:.3g} points").format(offset=offset)
1478+
# Translators: a measurement in Microsoft Word (points)
1479+
return _("{offset:.3g} pt").format(offset=offset)
14811480
elif unit==wdPicas:
14821481
offset=offset/12.0
14831482
# Translators: a measurement in Microsoft Word

0 commit comments

Comments
 (0)