Skip to content

Commit 0a5a8ac

Browse files
committed
Auto-indent on Enter, font search improvements, cross-platform install scripts
1 parent 9095ab2 commit 0a5a8ac

5 files changed

Lines changed: 146 additions & 11 deletions

File tree

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
name=C++ Mode
22
category=Other
3-
authors=[Jose Llamas](https://github.com/pepc84)
3+
authors=[Jose Gonzalez Llamas](https://github.com/pepc84)
44
url=https://github.com/processing-cpp/processing.cpp
5-
sentence=Write Processing sketches in C++, compiled to a native binary.
5+
sentence=Write and run Processing sketches in C++.
66
paragraph=C++ Mode lets you write sketches using the familiar Processing API — size(), ellipse(), mouseX, draw() — but compiled to a native binary via g++. Runs on Linux, macOS, and Windows (via MSYS2). Requires g++ and OpenGL (GLFW + GLEW).
77
version=1
88
prettyVersion=0.1.0
9-
minRevision=1275
9+
minRevision=1280
1010
maxRevision=0
11-
type=Mode
12-
download=https://github.com/processing-cpp/processing.cpp/releases/download/v0.1.0/cppMode.zip
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
"Processing Sans" fonts are just "Source Sans", but renamed to
2+
prevent conflicts on Windows with other versions of Source Sans.
3+
https://github.com/processing/processing/issues/4747
4+
5+
6+
Copyright 2010, 2012, 2014 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.
7+
8+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
9+
10+
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
11+
12+
13+
-----------------------------------------------------------
14+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
15+
-----------------------------------------------------------
16+
17+
PREAMBLE
18+
The goals of the Open Font License (OFL) are to stimulate worldwide
19+
development of collaborative font projects, to support the font creation
20+
efforts of academic and linguistic communities, and to provide a free and
21+
open framework in which fonts may be shared and improved in partnership
22+
with others.
23+
24+
The OFL allows the licensed fonts to be used, studied, modified and
25+
redistributed freely as long as they are not sold by themselves. The
26+
fonts, including any derivative works, can be bundled, embedded,
27+
redistributed and/or sold with any software provided that any reserved
28+
names are not used by derivative works. The fonts and derivatives,
29+
however, cannot be released under any other type of license. The
30+
requirement for fonts to remain under this license does not apply
31+
to any document created using the fonts or their derivatives.
32+
33+
DEFINITIONS
34+
"Font Software" refers to the set of files released by the Copyright
35+
Holder(s) under this license and clearly marked as such. This may
36+
include source files, build scripts and documentation.
37+
38+
"Reserved Font Name" refers to any names specified as such after the
39+
copyright statement(s).
40+
41+
"Original Version" refers to the collection of Font Software components as
42+
distributed by the Copyright Holder(s).
43+
44+
"Modified Version" refers to any derivative made by adding to, deleting,
45+
or substituting -- in part or in whole -- any of the components of the
46+
Original Version, by changing formats or by porting the Font Software to a
47+
new environment.
48+
49+
"Author" refers to any designer, engineer, programmer, technical
50+
writer or other person who contributed to the Font Software.
51+
52+
PERMISSION & CONDITIONS
53+
Permission is hereby granted, free of charge, to any person obtaining
54+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
55+
redistribute, and sell modified and unmodified copies of the Font
56+
Software, subject to the following conditions:
57+
58+
1) Neither the Font Software nor any of its individual components,
59+
in Original or Modified Versions, may be sold by itself.
60+
61+
2) Original or Modified Versions of the Font Software may be bundled,
62+
redistributed and/or sold with any software, provided that each copy
63+
contains the above copyright notice and this license. These can be
64+
included either as stand-alone text files, human-readable headers or
65+
in the appropriate machine-readable metadata fields within text or
66+
binary files as long as those fields can be easily viewed by the user.
67+
68+
3) No Modified Version of the Font Software may use the Reserved Font
69+
Name(s) unless explicit written permission is granted by the corresponding
70+
Copyright Holder. This restriction only applies to the primary font name as
71+
presented to the users.
72+
73+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
74+
Software shall not be used to promote, endorse or advertise any
75+
Modified Version, except to acknowledge the contribution(s) of the
76+
Copyright Holder(s) and the Author(s) or with their explicit written
77+
permission.
78+
79+
5) The Font Software, modified or unmodified, in part or in whole,
80+
must be distributed entirely under this license, and must not be
81+
distributed under any other license. The requirement for fonts to
82+
remain under this license does not apply to any document created
83+
using the Font Software.
84+
85+
TERMINATION
86+
This license becomes null and void if any of the above conditions are
87+
not met.
88+
89+
DISCLAIMER
90+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
91+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
92+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
93+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
94+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
95+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
96+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
97+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
98+
OTHER DEALINGS IN THE FONT SOFTWARE.
282 KB
Binary file not shown.

mode/CppMode.jar

8.13 KB
Binary file not shown.

src/Processing.cpp

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,12 +2896,51 @@ void run(){
28962896
// Auto-load default.ttf from project root as the default font
28972897
// (matches Processing Java's "a generic sans-serif font will be used")
28982898
// Try to load default.ttf from several common locations
2899-
if (!tryLoadTTF("default.ttf", g_textSize) &&
2900-
!tryLoadTTF("src/default.ttf", g_textSize) &&
2901-
!tryLoadTTF("fonts/default.ttf",g_textSize) &&
2902-
!tryLoadTTF("/home/pep/Projects/processing4/core/src/font/ProcessingSansPro-Regular.ttf", g_textSize)) {
2903-
std::cerr << "[font] default.ttf not found -- using bitmap fallback\n";
2904-
}
2899+
{
2900+
std::string _homeDir;
2901+
#ifdef _WIN32
2902+
if (const char* h = std::getenv("USERPROFILE")) _homeDir = h;
2903+
#else
2904+
if (const char* h = std::getenv("HOME")) _homeDir = h;
2905+
#endif
2906+
std::string _modePath;
2907+
if (const char* mp = std::getenv("PROCESSING_MODE_PATH"))
2908+
_modePath = std::string(mp) + "/";
2909+
2910+
// Font name used by Processing4
2911+
const std::string _font = "ProcessingSansPro-Regular.ttf";
2912+
2913+
// Check Documents/Processing on Windows (user sketchbook)
2914+
std::string _docsPath;
2915+
#ifdef _WIN32
2916+
if (const char* ud = std::getenv("USERPROFILE"))
2917+
_docsPath = std::string(ud) + "/Documents/Processing/";
2918+
#endif
2919+
2920+
if (!tryLoadTTF(_modePath + "fonts/" + _font, g_textSize) &&
2921+
!tryLoadTTF(_modePath + _font, g_textSize) &&
2922+
!tryLoadTTF(_docsPath + "modes/CppMode/fonts/" + _font, g_textSize) &&
2923+
// Windows: Processing4 install locations
2924+
!tryLoadTTF("C:/Program Files/Processing/core/library/" + _font, g_textSize) &&
2925+
!tryLoadTTF("C:/Program Files (x86)/Processing/core/library/" + _font, g_textSize) &&
2926+
!tryLoadTTF("C:/Program Files/processing-4.3/core/library/" + _font, g_textSize) &&
2927+
!tryLoadTTF(_homeDir + "/AppData/Local/Programs/Processing/core/library/" + _font, g_textSize) &&
2928+
// Windows: dev build
2929+
!tryLoadTTF(_homeDir + "/Projects/processing4/core/src/font/" + _font, g_textSize) &&
2930+
// Linux: installed Processing4
2931+
!tryLoadTTF("/usr/lib/processing4/core/library/" + _font, g_textSize) &&
2932+
!tryLoadTTF("/usr/share/processing4/core/library/" + _font, g_textSize) &&
2933+
!tryLoadTTF("/opt/processing4/core/library/" + _font, g_textSize) &&
2934+
!tryLoadTTF("/opt/processing/core/library/" + _font, g_textSize) &&
2935+
!tryLoadTTF(_homeDir + "/.local/share/processing4/core/library/" + _font, g_textSize) &&
2936+
!tryLoadTTF(_homeDir + "/processing-4.3/core/library/" + _font, g_textSize) &&
2937+
!tryLoadTTF(_homeDir + "/Projects/processing4/core/src/font/" + _font, g_textSize) &&
2938+
// macOS
2939+
!tryLoadTTF("/Applications/Processing.app/Contents/Java/core/library/" + _font, g_textSize) &&
2940+
!tryLoadTTF(_homeDir + "/Applications/Processing.app/Contents/Java/core/library/" + _font, g_textSize)) {
2941+
std::cerr << "[font] ProcessingSansPro-Regular.ttf not found -- using bitmap fallback\n";
2942+
}
2943+
}
29052944

29062945
glfwFocusWindow(gWindow); // ensure input focus on Windows
29072946

0 commit comments

Comments
 (0)