Skip to content

Commit

Permalink
Fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Jan 16, 2025
2 parents de12228 + 1a570f9 commit 43143a8
Show file tree
Hide file tree
Showing 43 changed files with 1,363 additions and 345 deletions.
9 changes: 3 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
interval: "monthly"
open-pull-requests-limit: 10

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
interval: "monthly"
open-pull-requests-limit: 10
groups:
npm-packages:
Expand All @@ -21,8 +19,7 @@ updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
interval: "monthly"
open-pull-requests-limit: 10
groups:
python-packages:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog for Fontra

## 2025-01-14

- Fixed a regression with the Font menu [Issue 1941](https://github.com/googlefonts/fontra/issues/1941), [PR 1942](https://github.com/googlefonts/fontra/pull/1942)
- Fixed a regression with messages from server [PR 1939](https://github.com/googlefonts/fontra/pull/1939)

## 2025-01-06

- Fixed bug related to deleting points [Issue 1910](https://github.com/googlefonts/fontra/issues/1910), [PR 1916](https://github.com/googlefonts/fontra/pull/1916)
Expand Down
332 changes: 166 additions & 166 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"chai-almost": "^1.0.1",
"mocha": "^11.0.1",
"prettier-plugin-organize-imports": "^4.1.0",
"prettier-plugin-sort-json": "^4.0.0",
"rollup": "^4.29.1"
"prettier-plugin-sort-json": "^4.1.1",
"rollup": "^4.30.1"
},
"dependencies": {
"bezier-js": "^6.1.4",
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mypy==1.14.1
pre-commit==4.0.1
pytest==8.3.4
pytest-asyncio==0.25.1
pytest-asyncio==0.25.2
types-PyYAML==6.0.12.20241230
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ pillow==11.1.0
pyyaml==6.0.2
ufomerge==1.8.2
unicodedata2==15.1.0
watchfiles==1.0.3
watchfiles==1.0.4
skia-pathops==0.8.0.post2
17 changes: 16 additions & 1 deletion src/fontra/client/core/font-controller.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { getClassSchema } from "../core/classes.js";
import { recordChanges } from "./change-recorder.js";
import {
applyChange,
collectChangePaths,
consolidateChanges,
filterChangePattern,
matchChangePattern,
} from "./changes.js";
import { getClassSchema } from "./classes.js";
import { getGlyphMapProxy, makeCharacterMapFromGlyphMap } from "./cmap.js";
import { CrossAxisMapping } from "./cross-axis-mapping.js";
import { FontSourcesInstancer } from "./font-sources-instancer.js";
Expand Down Expand Up @@ -681,6 +682,20 @@ export class FontController {
return editContext;
}

async performEdit(editLabel, rootKey, editFunc, senderID) {
// This is a convenience for non-continuous non-glyph changes
const root = { [rootKey]: await this.getData(rootKey) };
const changes = recordChanges(root, editFunc);
await this.postChange(changes.change, changes.rollbackChange, editLabel, senderID);
return changes;
}

async postChange(change, rollbackChange, editLabel, senderID) {
const error = await this.editFinal(change, rollbackChange, editLabel, true);
// TODO handle error
this.notifyEditListeners("editFinal", senderID);
}

async applyChange(change, isExternalChange) {
if (!isExternalChange && this.readOnly) {
console.log("can't edit font in read-only mode");
Expand Down
16 changes: 13 additions & 3 deletions src/fontra/client/core/fontra-menus.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { registerActionInfo } from "./actions.js";
import * as html from "./html-utils.js";
import { translate } from "./localization.js";
import { assert } from "./utils.js";
import { MenuBar } from "/web-components/menu-bar.js";
import { MenuItemDivider } from "/web-components/menu-panel.js";

Expand Down Expand Up @@ -166,7 +167,7 @@ function getFontMenuItems() {
enabled: () => enabled,
callback: () => {
const url = new URL(window.location);
url.pathname = `/fontinfo/-/${url.pathname.split("/").slice(-1)[0]}`;
url.pathname = rerouteViewPath(url.pathname, "fontinfo");
url.hash = panelID;
window.open(url.toString());
},
Expand All @@ -184,7 +185,7 @@ function getWindowMenuItems() {
enabled: () => true,
callback: () => {
const url = new URL(window.location);
url.pathname = `/fontoverview/-/${url.pathname.split("/").slice(-1)[0]}`;
url.pathname = rerouteViewPath(url.pathname, "fontoverview");
url.hash = ""; // remove any hash
window.open(url.toString());
},
Expand All @@ -194,14 +195,23 @@ function getWindowMenuItems() {
enabled: () => true,
callback: () => {
const url = new URL(window.location);
url.pathname = `/editor/-/${url.pathname.split("/").slice(-1)[0]}`;
url.pathname = rerouteViewPath(url.pathname, "editor");
url.hash = ""; // remove any hash
window.open(url.toString());
},
},
];
}

function rerouteViewPath(path, targetView) {
assert(path[0] === "/");
const parts = path.split("/");
assert(parts.length >= 3);
assert(parts[1].length > 0);
parts[1] = targetView;
return parts.join("/");
}

// Default action infos

{
Expand Down
2 changes: 2 additions & 0 deletions src/fontra/client/core/glyph-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export function getSuggestedGlyphName(codePoint) {
}

export function getCodePointFromGlyphName(glyphName) {
parseGlyphDataCSV();

const glyphInfo = glyphDataByName.get(glyphName);

let codePoint = null;
Expand Down
33 changes: 33 additions & 0 deletions src/fontra/client/core/parse-glyph-set.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { getCodePointFromGlyphName } from "./glyph-data.js";

export const glyphSetDataFormats = [
{ value: "auto-detect", label: "auto-detect" },
{ value: "glyph-names", label: "Glyph names (whitespace-separated)" },
{ value: "csv", label: "CSV (comma- or semicolon-separated)" },
{ value: "tsv", label: "TSV (tab-separated)" },
];

export function parseGlyphSet(sourceData, dataFormat) {
sourceData = sourceData.replaceAll("\r\n", "\n"); // normalize line endings

// TODO: TSV/CSV, etc.

const glyphSet = [];
for (let line of sourceData.split("\n")) {
const commentIndex = line.indexOf("#");
if (commentIndex >= 0) {
line = line.slice(0, commentIndex);
}
line = line.trim();
if (!line) {
continue;
}

for (const glyphName of line.split(/\s+/)) {
const codePoint = getCodePointFromGlyphName(glyphName);
glyphSet.push({ glyphName, codePoints: codePoint ? [codePoint] : [] });
}
}

return glyphSet;
}
53 changes: 28 additions & 25 deletions src/fontra/client/core/ui-utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as html from "./html-utils.js";
import { uniqueID, zip } from "./utils.js";
import { PopupMenu } from "/web-components/popup-menu.js";

const containerClassName = "fontra-ui-sortable-list-container";
const draggingClassName = "fontra-ui-sortable-list-dragging";
Expand Down Expand Up @@ -101,6 +102,13 @@ export function labeledCheckbox(label, controller, key, options) {
inputElement.checked = controller.model[key];
inputWrapper.appendChild(inputElement);
if (label) {
inputWrapper.style = `
display: grid;
grid-template-columns: auto auto;
justify-content: left;
gap: 0.1em;
align-items: center;
`;
inputWrapper.appendChild(html.label({ for: checkboxID }, [label]));
}

Expand Down Expand Up @@ -171,37 +179,32 @@ export function labeledTextInput(label, controller, key, options) {
return items;
}

export function popUpMenu(controller, key, menuItems, options) {
const popUpID = options?.id || `pop-up-${uniqueID()}-${key}`;

const selectElement = html.select(
{
id: popUpID,
onchange: (event) => {
controller.model[key] = event.target.value;
},
},
menuItems.map((menuItem) =>
html.option({ value: menuItem.identifier }, [menuItem.value])
)
);
selectElement.value = controller.model[key];
export function popupSelect(controller, key, popupItems) {
function findLabel() {
const option = popupItems.find(({ value }) => value === controller.model[key]);
return option?.label || "";
}

controller.addKeyListener(key, (event) => {
selectElement.value = event.newValue;
menu.valueLabel = findLabel();
});

if (options?.class) {
selectElement.className = options.class;
}

return selectElement;
const menu = new PopupMenu(findLabel(), () =>
popupItems.map(({ value, label }) => ({
title: label,
checked: value === controller.model[key],
callback: () => {
controller.model[key] = value;
menu.valueLabel = label;
},
}))
);
return menu;
}

export function labeledPopUpMenu(label, controller, key, menuItems, options) {
const popUpMenuElement = popUpMenu(controller, key, menuItems, options);
const items = [labelForElement(label, popUpMenuElement), popUpMenuElement];
return items;
export function labeledPopupSelect(label, controller, key, popupItems) {
const inputElement = popupSelect(controller, key, popupItems);
return [labelForElement(label, inputElement), inputElement];
}

export const DefaultFormatter = {
Expand Down
22 changes: 0 additions & 22 deletions src/fontra/client/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,6 @@ icon-button {
width: 1.25em;
}

input[type="button"] {
cursor: pointer;
background-color: #ddd;

border-radius: 1em;
padding: 0.35em 2em 0.35em 2em;

border: none;
font-family: fontra-ui-regular, sans-serif;
font-size: 1em;
text-align: center;
transition: 100ms;
}

input[type="button"]:hover {
background-color: #ccc;
}

input[type="button"]:active {
background-color: #bbb;
}

.top-bar-container {
position: relative; /* for z-index */
z-index: 200;
Expand Down
33 changes: 33 additions & 0 deletions src/fontra/client/css/shared.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,36 @@
*::after {
box-sizing: border-box;
}

.fontra-button {
cursor: pointer;
background-color: #ddd;

border-radius: 1em;
padding: 0.35em 2em 0.35em 2em;

border: none;
font-family: fontra-ui-regular, sans-serif;
font-size: 1em;
text-align: center;
transition: 100ms;
}

.fontra-button:hover {
background-color: #ccc;
}

.fontra-button:active {
background-color: #bbb;
}

/*
This is a workaround. We don't necessarily want to suppress the focus ring,
but we're running into a (Chrome) bug where a button gets focus when it
shouldn't: when a dialog gets dismissed with a key event, the button that
caused the dialog to *open* wrongly gets the focus.
*/
button,
input[type="button"]:focus {
outline: none;
}
1 change: 1 addition & 0 deletions src/fontra/client/lang/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const strings = {
"action.edit-guideline": "Hilfslinie bearbeiten",
"action.export-as.designspace": "Designspace + UFO (*.designspace)",
"action.export-as.fontra": "Fontra (*.fontra)",
"action.export-as.glyphs": "Glyphs (*.glyphs)",
"action.export-as.otf": "OpenType (*.otf)",
"action.export-as.rcjk": "RCJK (*.rcjk)",
"action.export-as.ttf": "TrueType (*.ttf)",
Expand Down
1 change: 1 addition & 0 deletions src/fontra/client/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const strings = {
"action.edit-guideline": "Edit Guideline",
"action.export-as.designspace": "Designspace + UFO (*.designspace)",
"action.export-as.fontra": "Fontra (*.fontra)",
"action.export-as.glyphs": "Glyphs (*.glyphs)",
"action.export-as.otf": "OpenType (*.otf)",
"action.export-as.rcjk": "RCJK (*.rcjk)",
"action.export-as.ttf": "TrueType (*.ttf)",
Expand Down
1 change: 1 addition & 0 deletions src/fontra/client/lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const strings = {
"action.edit-guideline": "Éditer le guide",
"action.export-as.designspace": "Designspace + UFO (*.designspace)",
"action.export-as.fontra": "Fontra (*.fontra)",
"action.export-as.glyphs": "Glyphs (*.glyphs)",
"action.export-as.otf": "OpenType (*.otf)",
"action.export-as.rcjk": "RCJK (*.rcjk)",
"action.export-as.ttf": "TrueType (*.ttf)",
Expand Down
1 change: 1 addition & 0 deletions src/fontra/client/lang/ja.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const strings = {
"action.edit-guideline": "ガイドラインを編集",
"action.export-as.designspace": "Designspace + UFO (*.designspace)",
"action.export-as.fontra": "Fontra (*.fontra)",
"action.export-as.glyphs": "Glyphs (*.glyphs)",
"action.export-as.otf": "OpenType (*.otf)",
"action.export-as.rcjk": "RCJK (*.rcjk)",
"action.export-as.ttf": "TrueType (*.ttf)",
Expand Down
1 change: 1 addition & 0 deletions src/fontra/client/lang/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const strings = {
"action.edit-guideline": "Edit Guideline",
"action.export-as.designspace": "Designspace + UFO (*.designspace)",
"action.export-as.fontra": "Fontra (*.fontra)",
"action.export-as.glyphs": "Glyphs (*.glyphs)",
"action.export-as.otf": "OpenType (*.otf)",
"action.export-as.rcjk": "RCJK (*.rcjk)",
"action.export-as.ttf": "TrueType (*.ttf)",
Expand Down
1 change: 1 addition & 0 deletions src/fontra/client/lang/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const strings = {
"action.edit-guideline": "编辑参考线",
"action.export-as.designspace": "Designspace + UFO (*.designspace)",
"action.export-as.fontra": "Fontra (*.fontra)",
"action.export-as.glyphs": "Glyphs (*.glyphs)",
"action.export-as.otf": "OpenType (*.otf)",
"action.export-as.rcjk": "RCJK (*.rcjk)",
"action.export-as.ttf": "TrueType (*.ttf)",
Expand Down
4 changes: 4 additions & 0 deletions src/fontra/client/web-components/add-remove-buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class AddRemoveButtons extends html.UnlitElement {
background-color: var(--button-active-color);
cursor: pointer;
}
button:focus {
outline: none;
}
`;

static properties = {
Expand Down
Loading

0 comments on commit 43143a8

Please sign in to comment.