Skip to content

Commit

Permalink
Revert "Adjust for font height between platforms"
Browse files Browse the repository at this point in the history
- This didn't work out
- This reverts commit 9b41d57
  • Loading branch information
Phillipus committed Aug 19, 2024
1 parent f199634 commit d22bb86
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public void run() {

// Set default font on first selected object
FontData fontData = FontFactory.getDefaultUserViewFontData();
String fontValue = FontFactory.getPlatformDependentFontString(model.getFont());
String rgbValue = null;

rgbValue = model.getFontColor();
String fontValue = model.getFont();
if(fontValue != null) {
try {
fontData = new FontData(fontValue);
Expand All @@ -86,7 +89,7 @@ public void run() {
dialog.setText(Messages.FontAction_1);
dialog.setEffectsVisible(false); // Don't allow underline/strikeout on Windows. See https://github.com/archimatetool/archi/issues/851
dialog.setFontList(new FontData[] { fontData } );
dialog.setRGB(ColorFactory.convertStringToRGB(model.getFontColor()));
dialog.setRGB(ColorFactory.convertStringToRGB(rgbValue));

FontData selectedFontData = dialog.open();
if(selectedFontData != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ public IDiagramModelObjectFigure getFigure() {
*/
@Override
protected void applicationPreferencesChanged(PropertyChangeEvent event) {
// Default font or colour preferences changed, or font scaling changed
// Default font or colour preferences changed
if(IPreferenceConstants.DEFAULT_VIEW_FONT.equals(event.getProperty()) ||
event.getProperty().startsWith(IPreferenceConstants.DEFAULT_FILL_COLOR_PREFIX) ||
event.getProperty().equals(IPreferenceConstants.DEFAULT_ELEMENT_LINE_COLOR) ||
event.getProperty().equals(IPreferenceConstants.PLATFORM_FONT_SCALING)) {
event.getProperty().equals(IPreferenceConstants.DEFAULT_ELEMENT_LINE_COLOR)) {

refreshFigure();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ else if(IPreferenceConstants.CONNECTION_LABEL_STRATEGY.equals(property)) {
else if(IPreferenceConstants.VIEWPOINTS_GHOST_DIAGRAM_ELEMENTS.equals(property)) {
getFigure().refreshVisuals();
}
else if(IPreferenceConstants.PLATFORM_FONT_SCALING.equals(property)) {
getFigure().refreshVisuals();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected void setDisabledState(Graphics graphics) {
* Set the font to that in the model, or failing that, as per user's default
*/
protected void setFont() {
String fontName = FontFactory.getPlatformDependentFontString(fDiagramModelObject.getFont());
String fontName = fDiagramModelObject.getFont();
setFont(FontFactory.get(fontName));

// Need to do this after font change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected void setConnectionText() {
* Set the font in the label to that in the model, or failing that, as per user's default
*/
protected void setLabelFont() {
String fontName = FontFactory.getPlatformDependentFontString(getModelConnection().getFont());
String fontName = getModelConnection().getFont();
Font font = FontFactory.get(fontName);

// Possible font scaling for non 96 DPI on Windows or if property set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public class GeneralPreferencePage
private Button fWarnOnDeleteButton;
private Button fShowSpecializationsModelTreeButton;

private Button fAddDocumentationNoteButton;
private Button fScaleImagesButton;
private Button fScaleFontsButton;

private Button fAddDocumentationNoteButton;

private Button fUseEdgeBrowserButton;

Expand Down Expand Up @@ -146,11 +146,6 @@ protected Control createContents(Composite parent) {
fScaleImagesButton.setLayoutData(createHorizontalGridData(2));
fScaleImagesButton.setToolTipText(Messages.GeneralPreferencePage_14);

fScaleFontsButton = new Button(otherGroup, SWT.CHECK);
fScaleFontsButton.setText(Messages.GeneralPreferencePage_25);
fScaleFontsButton.setLayoutData(createHorizontalGridData(2));
fScaleFontsButton.setToolTipText(Messages.GeneralPreferencePage_26);

// Internal Browser
Group browserGroup = new Group(client, SWT.NULL);
browserGroup.setText(Messages.GeneralPreferencePage_19);
Expand Down Expand Up @@ -227,8 +222,6 @@ private void setValues() {

fAddDocumentationNoteButton.setSelection(getPreferenceStore().getBoolean(ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE));

fScaleFontsButton.setSelection(getPreferenceStore().getBoolean(PLATFORM_FONT_SCALING));

if(fUseEdgeBrowserButton != null) {
fUseEdgeBrowserButton.setSelection(getPreferenceStore().getBoolean(EDGE_BROWSER));
}
Expand Down Expand Up @@ -261,8 +254,6 @@ public boolean performOk() {

getPreferenceStore().setValue(ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE, fAddDocumentationNoteButton.getSelection());

getPreferenceStore().setValue(PLATFORM_FONT_SCALING, fScaleFontsButton.getSelection());

if(fUseEdgeBrowserButton != null) {
getPreferenceStore().setValue(EDGE_BROWSER, fUseEdgeBrowserButton.getSelection());
}
Expand Down Expand Up @@ -297,8 +288,6 @@ protected void performDefaults() {

fAddDocumentationNoteButton.setSelection(getPreferenceStore().getDefaultBoolean(ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE));

fScaleFontsButton.setSelection(getPreferenceStore().getDefaultBoolean(PLATFORM_FONT_SCALING));

if(fUseEdgeBrowserButton != null) {
fUseEdgeBrowserButton.setSelection(getPreferenceStore().getDefaultBoolean(EDGE_BROWSER));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public interface IPreferenceConstants {
// Whether to use a line offset in all cases for figures drawn on hi-res screens
String USE_FIGURE_LINE_OFFSET = "figureLineOffset";

// Whether to add a note to the documentation field of relationships that have been changed to Association when setting a new concept type
String ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE = "addDocumentationNoteOnRelationChange";

// Appearance

String DEFAULT_ARCHIMATE_FIGURE_WIDTH = "defaultArchiMateFigureWidth";
Expand Down Expand Up @@ -132,10 +135,7 @@ public interface IPreferenceConstants {

String USE_LABEL_EXPRESSIONS_IN_ANALYSIS_TABLE = "useLabelExpressionInAnalysisTable";

// Whether to add a note to the documentation field of relationships that have been changed to Association when setting a new concept type
String ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE = "addDocumentationNoteOnRelationChange";
String SCALE_IMAGE_EXPORT = "scaleImageExport";
String PLATFORM_FONT_SCALING = "platformFontScaling";

// Animation
String ANIMATE_VIEW = "animateView";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,6 @@ public class Messages extends NLS {

public static String GeneralPreferencePage_24;

public static String GeneralPreferencePage_25;

public static String GeneralPreferencePage_26;

public static String GeneralPreferencePage_3;

public static String GeneralPreferencePage_4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public void initializeDefaultPreferences() {
// Windows at hi-res needs this set to true
store.setDefault(USE_FIGURE_LINE_OFFSET, PlatformUtils.isWindows() && ImageFactory.getDeviceZoom() > 100);

store.setDefault(ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE, false);

// Appearance

store.setDefault(DEFAULT_ARCHIMATE_FIGURE_WIDTH, 120);
Expand All @@ -129,10 +131,8 @@ public void initializeDefaultPreferences() {

store.setDefault(USE_LABEL_EXPRESSIONS_IN_ANALYSIS_TABLE, true);

store.setDefault(ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE, false);
// Windows hi-res and Mac Retina use 200 zoom, Linux is 100
store.setDefault(SCALE_IMAGE_EXPORT, (!PlatformUtils.isLinux() && ImageFactory.getDeviceZoom() > 100) ? true : false);
store.setDefault(PLATFORM_FONT_SCALING, true);

// Animation
store.setDefault(ANIMATE_VIEW, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ GeneralPreferencePage_21=Enable JavaScript in Hints
GeneralPreferencePage_22=Allow External Hosts in Hints
GeneralPreferencePage_23=If a connected relation type is changed as a result of changing an Element's type,\na note will be added to the Relation's documentation field.
GeneralPreferencePage_24=Show Specializations in "New" menu
GeneralPreferencePage_25=Adjust font height for each platform
GeneralPreferencePage_26=Adjust font height when a font height has been set on another operating system platform
GeneralPreferencePage_3=Animation
GeneralPreferencePage_4=Animate Views
GeneralPreferencePage_5=Automatically create a backup file (*.bak) when saving
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ else if(event.getProperty() == ColorChooser.PROP_COLORDEFAULT) {
};

/**
* Listen to default font change and font scaling in Prefs
* Listen to default font change in Prefs
*/
private IPropertyChangeListener prefsListener = event -> {
if(event.getProperty().startsWith(IPreferenceConstants.DEFAULT_VIEW_FONT)
|| IPreferenceConstants.PLATFORM_FONT_SCALING.equals(event.getProperty())) {
update();
private IPropertyChangeListener prefsListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if(event.getProperty().startsWith(IPreferenceConstants.DEFAULT_VIEW_FONT)) {
update();
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,39 +168,6 @@ public static Font getScaledFont96DPI(Font font) {
return font;
}

/**
* Return a FontData string with adjusted font height if the FontData string is not for the current platform.
* @param fontDataString The FontData string
* @return The Font Data String for the current platform or the same string if there is no change.
*/
public static String getPlatformDependentFontString(String fontDataString) {
if(StringUtils.isSet(fontDataString) && ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.PLATFORM_FONT_SCALING)) {
float factor = 0;

// On Mac but fontdata contains Windows or Linux
if(PlatformUtils.isMac() && (fontDataString.contains("|WINDOWS|") || fontDataString.contains("|GTK|"))) {
factor = (float)96 / 72;
}
// On Windows or Linux but font came from Mac
else if(!PlatformUtils.isMac() && fontDataString.contains("|COCOA|")) {
factor = (float)72 / 96;
}

if(factor != 0) {
try {
FontData fd = new FontData(fontDataString);
int newHeight = Math.round(fd.getHeight() * factor); // round up in this case
fd.setHeight(newHeight);
fontDataString = fd.toString();
}
catch(Exception ex) {
}
}
}

return fontDataString;
}

/**
* @param font
* @return The italic variant of the given font
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void chooseFont() {
protected void updateFont() {
fFontData = FontFactory.getDefaultUserViewFontData();

String fontValue = FontFactory.getPlatformDependentFontString(fFontObject.getFont());
String fontValue = fFontObject.getFont();
if(fontValue != null) {
try {
fFontData = new FontData(fontValue);
Expand Down Expand Up @@ -275,23 +275,34 @@ protected void updateButtonText() {
}

/**
* Adds a property change listener to listen for font change events.
* @param listener a property change listener
* Adds a property change listener to this <code>ColorSelector</code>.
* Events are fired when the color in the control changes via the user
* clicking an selecting a new one in the color dialog. No event is fired in
* the case where <code>setColorValue(RGB)</code> is invoked.
*
* @param listener
* a property change listener
*/
public void addListener(IPropertyChangeListener listener) {
addListenerObject(listener);
}

/**
* Removes the given listener. Has no effect if the listener is not registered.
* @param listener a property change listener
* Removes the given listener from this <code>ColorSelector</code>. Has
* no effect if the listener is not registered.
*
* @param listener
* a property change listener
*/
public void removeListener(IPropertyChangeListener listener) {
removeListenerObject(listener);
}

/**
* Fire the given event to listeners
* @param propertyName
* @param oldValue
* @param newValue
*/
private void fireActionListenerEvent(String propertyName, Object oldValue, Object newValue) {
final Object[] finalListeners = getListeners();
Expand Down
3 changes: 0 additions & 3 deletions com.archimatetool.help/help/Text/prefs_general.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ <h3>Other</h3>
When this is selected, images are exported and copied to the clipboard at twice their normal size. This is set on by default for Windows operating systems where display scaling is greater than 100%, and on Mac Retina devices. This is so that the exported image quality is not compromised since it is not possible to set a higher DPI in the image. This setting is usually not needed on Linux displays.</p>

<p>If the resulting image needs to be at its logical size you could edit it in an image editor and set the DPI to double its value. For example, on Mac change the DPI from to 72 to 144.</p>
<br/>

<p><strong>Adjust font height for each platform</strong><br/>
When this is selected, fonts are adjusted to match the DPI (dots per inch) setting for the current platform. For example, you might work on an Archi model on Windows and set the font height for an object to 10. However, when opening the model on Mac the font will appear too small because Mac uses 72 DPI while Windows uses 96 DPI. Conversely, you might set the font height on Mac but it appears too big on Windows. This setting adjusts for this difference so that font heights are the same on all platforms.</p>
<br/>

<h3>Internal Web Browser</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ Element writeFont(IFontAttribute fontObject, Element styleElement) {
try {
FontData fontData = null;

String fontString = FontFactory.getPlatformDependentFontString(fontObject.getFont());
String fontString = fontObject.getFont();
if(fontString != null) {
fontData = new FontData(fontString);
}
Expand Down

0 comments on commit d22bb86

Please sign in to comment.