Skip to content

Commit

Permalink
update to set main monospace font as Pitagon Sans Mono, and unifify t…
Browse files Browse the repository at this point in the history
…he font usage among all platforms
  • Loading branch information
sunny-chung committed Nov 15, 2024
1 parent f9aeba6 commit 6ab52a7
Show file tree
Hide file tree
Showing 17 changed files with 193 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- Certificates in P7B (PKCS#7) format can now be imported

### Changed
- The main monospace font has been changed to Pitagon Sans Mono and unified among all platforms
- Importing CA certificates now imports all the certificates from an input file
- Update the label of "Copy as PowerShell Invoke-WebRequest command" to confine supporting PowerShell version 6 or above only (there is no change to the underlying logic)
- Inherited values in Request Editor are now showing at the bottom rather than the top
Expand Down
93 changes: 93 additions & 0 deletions src/jvmMain/composeResources/font/pitagon_sans_mono/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2023 The Pitagon Sans Mono Project Authors (https://github.com/ThePitagon/pitagon-sans-mono)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.sunnychung.application.multiplatform.hellohttp.network.TransportClien
import com.sunnychung.application.multiplatform.hellohttp.manager.PersistResponseManager
import com.sunnychung.application.multiplatform.hellohttp.manager.PersistenceManager
import com.sunnychung.application.multiplatform.hellohttp.manager.PrettifierManager
import com.sunnychung.application.multiplatform.hellohttp.manager.ResourceManager
import com.sunnychung.application.multiplatform.hellohttp.manager.SingleInstanceProcessService
import com.sunnychung.application.multiplatform.hellohttp.network.GrpcTransportClient
import com.sunnychung.application.multiplatform.hellohttp.network.ReactorNettyHttpTransportClient
Expand All @@ -27,7 +28,7 @@ import com.sunnychung.application.multiplatform.hellohttp.ux.viewmodel.ResponseV
import com.sunnychung.application.multiplatform.hellohttp.ux.viewmodel.UserPreferenceViewModel
import java.io.File

class AppContext {
internal class AppContext {
val MetadataManager = MetadataManager()
val SingleInstanceProcessService = SingleInstanceProcessService()
val NetworkClientManager = NetworkClientManager()
Expand All @@ -40,6 +41,7 @@ class AppContext {
val PrettifierManager = PrettifierManager()
val PersistResponseManager = PersistResponseManager()
val AutoBackupManager = AutoBackupManager()
val ResourceManager = ResourceManager()

val RequestCollectionRepository = RequestCollectionRepository()
val ProjectCollectionRepository = ProjectCollectionRepository()
Expand Down Expand Up @@ -91,6 +93,8 @@ class AppContext {
get() = instance.PersistResponseManager
val AutoBackupManager: AutoBackupManager
get() = instance.AutoBackupManager
val ResourceManager: ResourceManager
get() = instance.ResourceManager
val RequestCollectionRepository: RequestCollectionRepository
get() = instance.RequestCollectionRepository
val ProjectCollectionRepository: ProjectCollectionRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ import com.sunnychung.application.multiplatform.hellohttp.ux.AppView
import com.sunnychung.application.multiplatform.hellohttp.ux.DataLossWarningDialogWindow
import io.github.dralletje.ktreesitter.graphql.TreeSitterGraphql
import io.github.treesitter.ktreesitter.json.TreeSitterJson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import net.harawata.appdirs.AppDirsFactory
import java.awt.Dimension
import java.io.File
Expand Down Expand Up @@ -72,21 +76,36 @@ fun main() {
}
loadNativeLibraries()
println("Preparing to start")
AppContext.PersistenceManager.initialize()

val dataVersion = AppContext.OperationalRepository.read(OperationalDI())!!.data.appVersion.let { Version(it) }
val appVersion = AppContext.MetadataManager.version.let { Version(it) }
var dataVersion: Version? = null
var appVersion: Version? = null

coroutineScope {
withContext(Dispatchers.IO) {
launch {
AppContext.PersistenceManager.initialize()

dataVersion =
AppContext.OperationalRepository.read(OperationalDI())!!.data.appVersion.let { Version(it) }
appVersion = AppContext.MetadataManager.version.let { Version(it) }
}

launch {
AppContext.ResourceManager.loadAllResources()
}
}
}

val prepareCounter = AtomicInteger(0)

application {
var isContinue by remember { mutableStateOf<Boolean?>(null) }
var isPrepared by remember { mutableStateOf(false) }
if (isContinue == null) {
if (dataVersion > appVersion) {
if (dataVersion!! > appVersion!!) {
DataLossWarningDialogWindow(
dataVersion = dataVersion.versionName,
appVersion = appVersion.versionName
dataVersion = dataVersion!!.versionName,
appVersion = appVersion!!.versionName
) {
isContinue = it
}
Expand All @@ -106,7 +125,7 @@ fun main() {

AppContext.OperationalRepository.read(OperationalDI())
.also {
it!!.data.appVersion = appVersion.versionName
it!!.data.appVersion = appVersion!!.versionName
AppContext.OperationalRepository.awaitUpdate(OperationalDI())
}
AppContext.AutoBackupManager.backupNow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ fun CodeEditorView(
log.d { "CodeEditorView start" }

val themeColours = LocalColor.current
val fonts = LocalFont.current
val coroutineScope = rememberCoroutineScope()

val inputFilter = BigTextInputFilter { it.replace("\r\n".toRegex(), "\n") }
Expand Down Expand Up @@ -307,7 +308,7 @@ fun CodeEditorView(
if (isEnableVariables) {
listOf(
EnvironmentVariableIncrementalTransformation(),
FunctionIncrementalTransformation(themeColours)
FunctionIncrementalTransformation(themeColours, fonts)
)
} else {
emptyList()
Expand All @@ -317,7 +318,7 @@ fun CodeEditorView(
val variableDecorators = remember(bigTextFieldState, themeColours, isEnableVariables, knownVariables) {
if (isEnableVariables) {
listOf(
EnvironmentVariableDecorator(themeColours, knownVariables.keys),
EnvironmentVariableDecorator(themeColours, fonts, knownVariables.keys),
)
} else {
emptyList()
Expand Down Expand Up @@ -478,7 +479,8 @@ fun CodeEditorView(
MultipleTextDecorator(syntaxHighlightDecorators + searchDecorators)
//},
,
fontSize = LocalFont.current.codeEditorBodyFontSize,
fontSize = fonts.codeEditorBodyFontSize,
fontFamily = fonts.monospaceFontFamily,
isSelectable = true,
scrollState = scrollState,
viewState = bigTextFieldState.viewState,
Expand Down Expand Up @@ -548,7 +550,8 @@ fun CodeEditorView(
//},
,
color = textColor,
fontSize = LocalFont.current.codeEditorBodyFontSize,
fontSize = fonts.codeEditorBodyFontSize,
fontFamily = fonts.monospaceFontFamily,
scrollState = scrollState,
onTextLayout = { layoutResult = it },
onTextManipulatorReady = onTextManipulatorReady,
Expand Down Expand Up @@ -707,7 +710,7 @@ fun BigTextLineNumbersView(

val textStyle = LocalTextStyle.current.copy(
fontSize = fonts.codeEditorLineNumberFontSize,
fontFamily = FontFamily.Monospace,
fontFamily = LocalFont.current.monospaceFontFamily,
color = colours.unimportant,
)
val collapsedLinesState = CollapsedLinesState(collapsableLines = collapsableLines, collapsedLines = collapsedLines)
Expand Down Expand Up @@ -801,7 +804,6 @@ private fun CoreLineNumbersView(
text = "${i + 1}",
style = textStyle,
fontSize = fonts.codeEditorLineNumberFontSize,
fontFamily = FontFamily.Monospace,
maxLines = 1,
color = colours.unimportant,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.sunnychung.application.multiplatform.hellohttp.model.UserKeyValuePair
import com.sunnychung.application.multiplatform.hellohttp.util.log
import com.sunnychung.application.multiplatform.hellohttp.util.uuidString
import com.sunnychung.application.multiplatform.hellohttp.ux.local.LocalColor
import com.sunnychung.application.multiplatform.hellohttp.ux.local.LocalFont
import com.sunnychung.application.multiplatform.hellohttp.ux.transformation.EnvironmentVariableTransformation
import com.sunnychung.application.multiplatform.hellohttp.ux.transformation.FunctionTransformation
import com.sunnychung.application.multiplatform.hellohttp.ux.transformation.MultipleVisualTransformation
Expand Down Expand Up @@ -129,9 +130,10 @@ fun KeyValueEditorView(
MultipleVisualTransformation(listOf(
EnvironmentVariableTransformation(
themeColors = colors,
font = LocalFont.current,
knownVariables = knownVariables.keys
),
FunctionTransformation(themeColors = colors),
FunctionTransformation(themeColors = colors, font = LocalFont.current),
))
} else {
VisualTransformation.None
Expand Down Expand Up @@ -170,9 +172,10 @@ fun KeyValueEditorView(
MultipleVisualTransformation(listOf(
EnvironmentVariableTransformation(
themeColors = colors,
font = LocalFont.current,
knownVariables = knownVariables.keys
),
FunctionTransformation(themeColors = colors),
FunctionTransformation(themeColors = colors, font = LocalFont.current),
))
} else {
VisualTransformation.None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ fun RequestEditorView(
},
visualTransformation = EnvironmentVariableTransformation(
themeColors = colors,
font = fonts,
knownVariables = mergedVariables.keys
),
singleLine = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,13 +585,13 @@ fun BodyViewerView(
placeholder = {
AppText(
text = "JSON Path, e.g. $.items.length()",
fontFamily = FontFamily.Monospace,
fontFamily = fonts.monospaceFontFamily,
fontSize = fonts.codeEditorBodyFontSize,
color = colours.placeholder
)
},
textStyle = LocalTextStyle.current.copy(
fontFamily = FontFamily.Monospace,
fontFamily = fonts.monospaceFontFamily,
fontSize = fonts.codeEditorBodyFontSize,
),
singleLine = true,
Expand Down Expand Up @@ -773,7 +773,7 @@ fun ResponseStreamView(response: UserResponse) {
AppText(
text = DATE_TIME_FORMAT.format(it.instant.atZoneOffset(KZoneOffset.local())),
color = textColour,
fontFamily = FontFamily.Monospace,
fontFamily = fonts.monospaceFontFamily,
fontSize = fonts.streamFontSize,
textAlign = TextAlign.Center,
modifier = Modifier.width(TIMESTAMP_COLUMN_WIDTH_DP)
Expand All @@ -788,7 +788,7 @@ fun ResponseStreamView(response: UserResponse) {
PayloadMessage.Type.Error -> "x"
},
color = textColour,
fontFamily = FontFamily.Monospace,
fontFamily = fonts.monospaceFontFamily,
fontSize = fonts.streamFontSize,
textAlign = TextAlign.Center,
modifier = Modifier.width(TYPE_COLUMN_WIDTH_DP)
Expand All @@ -799,7 +799,7 @@ fun ResponseStreamView(response: UserResponse) {
isDisableWordWrap = true,
softWrap = false,
maxLines = 1,
fontFamily = FontFamily.Monospace,
fontFamily = fonts.monospaceFontFamily,
fontSize = fonts.streamFontSize,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f).padding(horizontal = 6.dp)
Expand Down
Loading

0 comments on commit 6ab52a7

Please sign in to comment.